from typing import Optional, List
from pydantic import BaseModel, ConfigDict, Field
from pydantic.alias_generators import to_camel

from module_admin.annotation.pydantic_annotation import as_query


class FutureTradeCalModel(BaseModel):
    """
    期货交易日历表对应pydantic模型
    """

    model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)

    id: Optional[int] = Field(default=None, description='主键')
    cal_date: Optional[str] = Field(default=None, description='日历日期')
    is_open: Optional[int] = Field(default=1, description='是否交易 0休市 1交易')
    pretrade_date: Optional[str] = Field(default=None, description='上一个交易日')
    create_time: Optional[str] = Field(default=None, description='创建时间')
    update_time: Optional[str] = Field(default=None, description='更新时间')


@as_query
class FutureTradeCalQueryModel(BaseModel):
    """
    期货交易日历不分页查询模型
    """
    
    model_config = ConfigDict(alias_generator=to_camel)
    
    begin_date: Optional[str] = Field(default=None, description='开始日期')
    end_date: Optional[str] = Field(default=None, description='结束日期')
    is_open: Optional[int] = Field(default=None, description='是否交易')


@as_query
class FutureTradeCalPageQueryModel(FutureTradeCalQueryModel):
    """
    期货交易日历分页查询模型
    """
    
    page_num: int = Field(default=1, description='当前页码')
    page_size: int = Field(default=10, description='每页记录数')


class DeleteFutureTradeCalModel(BaseModel):
    """
    删除期货交易日历请求模型
    """
    
    model_config = ConfigDict(alias_generator=to_camel)
    
    cal_ids: List[int] = Field(description='交易日历ID列表')


class UpdateFutureTradeCalModel(BaseModel):
    """
    更新期货交易日历请求模型
    """
    
    model_config = ConfigDict(alias_generator=to_camel)
    
    id: int = Field(description='主键')
    is_open: int = Field(description='是否交易 0休市 1交易')
    pretrade_date: Optional[str] = Field(default=None, description='上一个交易日')